package com.comment.exception;

import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;

public class ServiceException extends RuntimeException {
    public ServiceException(String msg) {
        super(msg);
    }

    public ServiceException(String msg, Object data) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("msg", msg);
        jsonObject.put("data", data);
        String jsonString = JSON.toJSONString(jsonObject);
        throw new ServiceException(jsonString);
    }
}
